#include "Common.hpp"

// pagecache.hpp
// 单例模式
class PageCache
{
public:
	// 提供一个全局访问点
	static PageCache *GetInc()
	{
		return &_sInc;
	}
	Span *NewSpan(size_t N);

	Span *MapObjectToSpan(void *obj);
	void ReleaseSpanToPageCache(Span* span);

	std::mutex _pageMtx; // 大锁

private:
	SpanList _spanLists[NPAGES];
	std::unordered_map<PAGE_ID, Span *> _idSpanMap;

private:
	PageCache() // 构造函数私有
	{
	}
	PageCache(const PageCache &) = delete; // 防拷贝
	static PageCache _sInc;
};
